package com.itheima;

import com.itheima.service.BookService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


/**
 * 1.bean的别名
 *      直接在<bean>标签中加个 name 属性 别名之间可以用逗号，分号，空格隔开</bean>
 * 2.bean的作用范围：bean是单例还是非单例？        -->默认是单例
 *      想变成非单例的话就去<bean>标签中配置scope属性</bean>
 */
public class AppForName {

    public static void main(String[] args) {

        ApplicationContext cx = new ClassPathXmlApplicationContext("applicationContext.xml");

        BookService bookService = (BookService) cx.getBean("bookService");

        bookService.save();

        BookService bookService1 = (BookService) cx.getBean("bookService");
        System.out.println(bookService1);

        BookService bookService2 = (BookService) cx.getBean("bookService");
        System.out.println(bookService2);
    }
}
